<?php 

$i = 0;

$recipients="";
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) 
{
	if(ereg("^Email",$key))
	{
		$addresses = explode("|",$val);
		$StrippedSubject = stripslashes($Subject);
		$StrippedMessage = stripslashes($Message);
		while (list($index,$address) = each($addresses))
		{
			$recipients = $recipients . $address . ";";
			email("choir",$address,$StrippedSubject,$StrippedMessage);
		}
	}
}

$base="stgeorgesparis.com";
$login="stgeorgesparis.com";
$pwd="michael";

$db=mysql_connect("sql.stgeorgesparis.com", $login, $pwd);

if(!$db)
{
	print "erreur connection $db<br>";
	exit;
}

// on choisit la bonne base
if(!mysql_select_db($base,$db)){
print "erreur ".mysql_error()."<br>";
mysql_close($db);
exit;
}


$sql="INSERT INTO mail (Subject, Message, Recipients) VALUES(\"$Subject\", \"$Message\", \"$recipients\")";
// une requete
if(!mysql_query($sql,$db))
{
	print "erreur $sql <br>";
}

mysql_close($db);

header("Location: http://music.stgeorgesparis.com/adminchoir/listmail");
?>


